$:.unshift File.join(File.dirname(__FILE__), "..", "lib")

require 'EventSet'

class Class
   def publicize_methods
     saved_private_instance_methods = self.private_instance_methods
     self.class_eval { public *saved_private_instance_methods }
       yield
     self.class_eval { private *saved_private_instance_methods }
   end
end

E1 = Event.new(:nodeid => 3, :type => :send, :origin=> 1)
E2 = Event.new(:nodeid => 3, :type => :send, :origin=> 2)
E3 = Event.new(:nodeid => 3, :type => :send, :origin=> 3)
E = EventSet.new()

def profile_ruby_permutations(i)

  (0...i).each do    
   subsetlist = Array.new()
    subsetlist << E1
    subsetlist << E2
    subsetlist << E3
   
    resultlist = Array.new()
    resultlist << subsetlist
    newsubsetlist = Array.new()
    newsubsetlist << E1 << E3 << E2
    resultlist << newsubsetlist
    newsubsetlist = Array.new()
    newsubsetlist << E2 << E1 << E3
    resultlist << newsubsetlist
    newsubsetlist = Array.new()
    newsubsetlist << E2 << E3 << E1
    resultlist << newsubsetlist
    newsubsetlist = Array.new()
    newsubsetlist << E3 << E1 << E2
    resultlist << newsubsetlist
    newsubsetlist = Array.new()
    newsubsetlist << E3 << E2 << E1
    resultlist << newsubsetlist
   
    solutions = Array.new()
    EventSet.publicize_methods do
       solutions = E.ruby_permutations(subsetlist)
    end
   end
  
end

profile_rub_permutations(100000)